package com.lorizz.picpub.task.impl;

import java.util.ArrayList;
import java.util.List;

import com.lorizz.index.Action;
import com.lorizz.index.Indexer;
import com.lorizz.index.Item;
import com.lorizz.index.impl.ItemImpl;
import com.lorizz.upm.Image;
import com.lorizz.upm.ImageIndexTask;
import com.lorizz.upm.IndexAction;

public class ImageIndexTaskExecutor extends AbstractTaskExecutor<ImageIndexTask> {

	private Indexer<Image> indexer;

	public void setIndexer(Indexer<Image> indexer) {
		this.indexer = indexer;
	}

	@Override
	protected void executeTask(ImageIndexTask task) {
		Image image = task.getImage();
		IndexAction action = task.getAction();
		Item<Image> item = new ItemImpl<Image>(image, Action.valueOf(action.name()), null);
		List<Item<Image>> items = new ArrayList<Item<Image>>();
		items.add(item);
		indexer.index(items);
	}

}
